home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1995 October
/
EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso
/
Aminet
/
util
/
dtype
/
cdt_39_10.lha
/
cdt
/
source
/
RCS
/
cdt.tab.c,v
< prev
next >
Wrap
Text File
|
1995-06-04
|
57KB
|
2,169 lines
head 39.13;
access;
symbols
V39_10:39.12
c3910:39.13
V39_9:39.10;
locks; strict;
comment @** @;
39.13
date 95.06.04.18.53.53; author StRuppert; state Exp;
branches;
next 39.12;
39.12
date 95.06.04.17.04.11; author StRuppert; state Exp;
branches;
next 39.11;
39.11
date 95.06.04.16.55.55; author StRuppert; state Exp;
branches;
next 39.10;
39.10
date 95.05.10.14.58.53; author StRuppert; state Exp;
branches;
next ;
desc
@initial
@
39.13
log
@*** empty log message ***
@
text
@
/* A Bison parser, made from cdt.y with Bison version GNU Bison version 1.22
*/
#define YYBISON 1 /* Identify Bison output. */
#define yyparse cdtparse_parse
#define yylex cdtparse_lex
#define yyerror cdtparse_error
#define yylval cdtparse_lval
#define yychar cdtparse_char
#define yydebug cdtparse_debug
#define yynerrs cdtparse_nerrs
#define T_INCLUDE 258
#define T_DEFINE 259
#define T_UNDEF 260
#define T_PRAGMA 261
#define T_LINE 262
#define T_ERROR 263
#define T_IF 264
#define T_IFDEF 265
#define T_IFNDEF 266
#define T_ELIF 267
#define T_ENDIF 268
#define T_AUTO 269
#define T_EXTERN 270
#define T_REGISTER 271
#define T_STATIC 272
#define T_CHAR 273
#define T_SHORT 274
#define T_INT 275
#define T_LONG 276
#define T_SIGNED 277
#define T_UNSIGNED 278
#define T_FLOAT 279
#define T_DOUBLE 280
#define T_VOID 281
#define T_USERTYPE 282
#define T_SWITCH 283
#define T_CASE 284
#define T_BREAK 285
#define T_DEFAULT 286
#define T_ELSE 287
#define T_FOR 288
#define T_DO 289
#define T_WHILE 290
#define T_CONTINUE 291
#define T_CONST 292
#define T_VOLATILE 293
#define T_GOTO 294
#define T_RETURN 295
#define T_STRUCT 296
#define T_UNION 297
#define T_ENUM 298
#define T_TYPEDEF 299
#define T_SIZEOF 300
#define T_CLASS 301
#define T_PUBLIC 302
#define T_PRIVATE 303
#define T_PROTECTED 304
#define T_VIRTUAL 305
#define T_FRIEND 306
#define T_NEW 307
#define T_DELETE 308
#define T_OPERATOR 309
#define T_TRY 310
#define T_CATCH 311
#define T_THROW 312
#define T_INLINE 313
#define T_ID 314
#define T_CHR 315
#define T_NUMBER 316
#line 1 "cdt.y"
/*
** $PROJECT: c.datatype
**
** $VER: cdt.y 39.12 (04.06.95)
**
** by
**
** Stefan Ruppert , Windthorststraße 5 , 65439 Flörsheim , GERMANY
**
** (C) Copyright 1995
** All Rights Reserved !
**
** $HISTORY:
**
** 04.06.95 : 039.012 : fixed c++ comment bug, which was damaged by the V39.11 changes
** 04.06.95 : 039.011 : handles tabs and spaces correctly, also for printing
** 10.05.95 : 039.010 : added userdefined types
** 28.04.95 : 039.009 : fixed tab calculation after a // comment
** 26.04.95 : 039.008 : fixed bug,a \ at the end of the line within a string wasn't handled correctly
** 22.04.95 : 039.007 : two bugs fixed (// comments and \ after a string)
** 14.04.95 : 039.006 : added nested switch
** 07.04.95 : 039.005 : else keyword wasn't correct sorted
** 24.03.95 : 039.004 : missing else keyword added
** 23.03.95 : 039.003 : now full tabs handling
** 12.03.95 : 039.002 : added C++ keywords
** 07.03.95 : 039.001 : initial
*/
#include "classbase.h"
/*FS*/ void add_line(struct ClassBase *cb,struct CParse *cparse,ULONG index,UWORD flags)
{
struct Style *style = &cparse->Data->cd_CStyle[index];
struct Line *line;
/* ignore segments , which are marked as text and no tabs are found ! */
if(!(style->Style == ~0 && index != C_STANDARD && cparse->XOffsetAdd == 0) || (flags & LNF_LF))
{
if((line = AllocPooled(cparse->Data->cd_Pool,sizeof(struct Line))))
{
struct Line *tabline = NULL;
STRPTR ptr = cparse->SegPtr;
if((style->Style & FSF_UNDERLINED) || cparse->XOffsetAdd > 0)
{
ULONG x = cparse->XOffsetAdd;
while(*ptr == ' ' || *ptr == '\t')
{
if(*ptr++ == ' ')
x++;
}
if((tabline = AllocPooled(cparse->Data->cd_Pool,sizeof(struct Line))))
{
tabline->ln_Text = cparse->Data->cd_TabBuffer;
tabline->ln_TextLen = x;
tabline->ln_XOffset = cparse->XOffset;
tabline->ln_YOffset = cparse->YOffset;
x *= cparse->TabWidth;
tabline->ln_Width = x;
tabline->ln_Height = cparse->RPort->TxHeight;
tabline->ln_Flags = 0;
tabline->ln_FgPen = style->FgPen;
tabline->ln_BgPen = style->BgPen;
tabline->ln_Style = FS_NORMAL;
cparse->XOffset += x;
AddTail(cparse->LineList,(struct Node *) tabline);
}
}
line->ln_Text = ptr;
if(ptr < cparse->ActPtr)
line->ln_TextLen = cparse->ActPtr - ptr;
else
{
line->ln_TextLen = 0;
line->ln_Text = NULL;
}
if((flags & LNF_LF) && line->ln_TextLen > 0)
line->ln_TextLen--;
line->ln_XOffset = cparse->XOffset;
line->ln_YOffset = cparse->YOffset;
line->ln_Width = TextLength(cparse->RPort,line->ln_Text,line->ln_TextLen);
line->ln_Height = cparse->RPort->TxHeight;
line->ln_Flags = flags;
line->ln_FgPen = style->FgPen;
line->ln_BgPen = style->BgPen;
if(style->Style != ~0)
line->ln_Style = style->Style;
else
line->ln_Style = FS_NORMAL;
if(flags & LNF_LF)
{
if(cparse->XOffset + line->ln_Width > cparse->MaxWidth)
cparse->MaxWidth = cparse->XOffset + line->ln_Width;
cparse->YOffset += line->ln_Height;
cparse->XOffset = 0;
} else
{
cparse->XOffset += line->ln_Width;
D({
STRPTR ptr = &line->ln_Text[line->ln_TextLen];
UBYTE help = *ptr;
*ptr = '\0';
bug("text : %s\n",line->ln_Text);
*ptr = help;
});
}
cparse->XOffsetAdd = 0;
cparse->SegPtr = cparse->ActPtr;
AddTail(cparse->LineList,(struct Node *) line);
}
}
}
/*FE*/
/*FS*/ void add_cexpr(struct ClassBase *cb,struct CParse *cparse,ULONG index,BOOL lf)
{
if(cparse->TxtPtr > cparse->SegPtr && *cparse->SegPtr != '\n')
{
STRPTR actptr = cparse->ActPtr;
ULONG index = (cparse->Mode < C_MAX) ? cparse->Mode : C_STANDARD;
ULONG x = cparse->XOffsetAdd;
cparse->XOffsetAdd = 0;
cparse->ActPtr = cparse->TxtPtr;
add_line(cb,cparse,index,0);
cparse->XOffsetAdd = x;
cparse->SegPtr = cparse->ActPtr;
cparse->ActPtr = actptr;
}
add_line(cb,cparse,index,lf);
cparse->TxtPtr = cparse->ActPtr;
}
/*FE*/
#ifndef YYLTYPE
typedef
struct yyltype
{
int timestamp;
int first_line;
int first_column;
int last_line;
int last_column;
char *text;
}
yyltype;
#define YYLTYPE yyltype
#endif
#ifndef YYSTYPE
#define YYSTYPE int
#endif
#include <stdio.h>
#ifndef __cplusplus
#ifndef __STDC__
#ifndef const
#define const
#endif
#endif
#endif
#define YYFINAL 147
#define YYFLAG -32768
#define YYNTBASE 67
#define YYTRANSLATE(x) ((unsigned)(x) <= 316 ? yytranslate[x] : 101)
static const char yytranslate[] = { 0,
2, 2, 2, 2, 2, 2, 2, 2, 2, 63,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 64, 62, 2, 2, 2, 65, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 66, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
56, 57, 58, 59, 60, 61
};
#if YYDEBUG != 0
static const short yyprhs[] = { 0,
0, 2, 5, 6, 10, 12, 14, 16, 18, 20,
23, 24, 28, 30, 32, 34, 36, 38, 40, 42,
44, 46, 48, 50, 52, 53, 55, 56, 57, 63,
64, 66, 68, 71, 73, 75, 77, 81, 85, 87,
88, 93, 95, 97, 99, 101, 103, 105, 107, 109,
111, 113, 115, 117, 119, 121, 123, 125, 127, 129,
131, 133, 135, 137, 139, 141, 143, 145, 147, 149,
151, 153, 155, 156, 160, 161, 165, 167, 169, 171,
172, 174, 176, 178, 180, 182, 184, 186, 188, 190,
192, 194, 196, 198, 200, 202, 204, 207, 209, 211,
213, 217, 218, 219, 226, 227, 229, 231, 233, 235,
237, 240, 241, 244, 246, 249, 250, 252, 254, 256,
258, 260, 263, 265, 267, 269, 271, 273, 275
};
static const short yyrhs[] = { 68,
0, 67, 68, 0, 0, 62, 69, 70, 0, 63,
0, 90, 0, 91, 0, 82, 0, 92, 0, 71,
63, 0, 0, 73, 72, 74, 0, 75, 0, 3,
0, 5, 0, 6, 0, 7, 0, 8, 0, 9,
0, 10, 0, 11, 0, 12, 0, 13, 0, 32,
0, 0, 92, 0, 0, 0, 4, 76, 59, 77,
78, 0, 0, 79, 0, 80, 0, 79, 80, 0,
59, 0, 60, 0, 61, 0, 64, 98, 64, 0,
65, 96, 65, 0, 62, 0, 0, 66, 63, 81,
78, 0, 83, 0, 84, 0, 37, 0, 38, 0,
28, 0, 29, 0, 30, 0, 9, 0, 32, 0,
33, 0, 34, 0, 35, 0, 36, 0, 40, 0,
31, 0, 39, 0, 44, 0, 45, 0, 47, 0,
48, 0, 49, 0, 50, 0, 51, 0, 52, 0,
53, 0, 54, 0, 55, 0, 56, 0, 57, 0,
58, 0, 85, 0, 0, 88, 86, 89, 0, 0,
43, 87, 89, 0, 41, 0, 42, 0, 46, 0,
0, 59, 0, 18, 0, 19, 0, 20, 0, 21,
0, 22, 0, 23, 0, 24, 0, 25, 0, 26,
0, 27, 0, 14, 0, 15, 0, 17, 0, 16,
0, 93, 0, 92, 93, 0, 59, 0, 60, 0,
61, 0, 65, 96, 65, 0, 0, 0, 64, 94,
98, 64, 95, 97, 0, 0, 59, 0, 60, 0,
61, 0, 64, 0, 62, 0, 66, 100, 0, 0,
66, 63, 0, 99, 0, 98, 99, 0, 0, 59,
0, 60, 0, 61, 0, 65, 0, 62, 0, 66,
100, 0, 59, 0, 60, 0, 61, 0, 64, 0,
66, 0, 65, 0, 63, 0
};
#endif
#if YYDEBUG != 0
static const short yyrline[] = { 0,
199, 200, 203, 205, 206, 207, 208, 209, 210, 213,
217, 220, 220, 223, 225, 226, 227, 228, 229, 230,
231, 232, 233, 234, 237, 238, 241, 243, 245, 247,
248, 251, 254, 258, 260, 261, 262, 263, 264, 265,
267, 271, 273, 275, 277, 278, 279, 280, 281, 282,
283, 284, 285, 286, 287, 288, 289, 290, 291, 292,
293, 294, 295, 296, 297, 298, 299, 300, 301, 302,
303, 306, 310, 313, 313, 315, 317, 319, 320, 323,
324, 327, 329, 330, 331, 332, 333, 334, 335, 336,
337, 340, 342, 343, 344, 347, 350, 354, 356, 357,
358, 361, 364, 367, 369, 370, 371, 372, 373, 374,
375, 379, 380, 383, 385, 389, 390, 391, 392, 393,
394, 395, 398, 400, 401, 402, 403, 404, 405
};
static const char * const yytname[] = { "$","error","$illegal.","T_INCLUDE",
"T_DEFINE","T_UNDEF","T_PRAGMA","T_LINE","T_ERROR","T_IF","T_IFDEF","T_IFNDEF",
"T_ELIF","T_ENDIF","T_AUTO","T_EXTERN","T_REGISTER","T_STATIC","T_CHAR","T_SHORT",
"T_INT","T_LONG","T_SIGNED","T_UNSIGNED","T_FLOAT","T_DOUBLE","T_VOID","T_USERTYPE",
"T_SWITCH","T_CASE","T_BREAK","T_DEFAULT","T_ELSE","T_FOR","T_DO","T_WHILE",
"T_CONTINUE","T_CONST","T_VOLATILE","T_GOTO","T_RETURN","T_STRUCT","T_UNION",
"T_ENUM","T_TYPEDEF","T_SIZEOF","T_CLASS","T_PUBLIC","T_PRIVATE","T_PROTECTED",
"T_VIRTUAL","T_FRIEND","T_NEW","T_DELETE","T_OPERATOR","T_TRY","T_CATCH","T_THROW",
"T_INLINE","T_ID","T_CHR","T_NUMBER","'#'","'\\n'","'\"'","'\\''","'\\\\'","input",
"statement","@@1","cpp","cppline","@@2","cppkeyword","cpptextlist","define","@@3",
"@@4","definelist","definetextlist","definetext","@@5","keywords","keywordsincomplete",
"keywordscomplete","elaborated_type_specifier","@@6","@@7","class_key","elaborated_type_specifier_name",
"simple_type_name","storage_class","textlist","text","@@8","@@9","char","stringend",
"stringinner","stringtoken","stringescaped",""
};
#endif
static const short yyr1[] = { 0,
67, 67, 69, 68, 68, 68, 68, 68, 68, 70,
72, 71, 71, 73, 73, 73, 73, 73, 73, 73,
73, 73, 73, 73, 74, 74, 76, 77, 75, 78,
78, 79, 79, 80, 80, 80, 80, 80, 80, 81,
80, 82, 82, 83, 83, 83, 83, 83, 83, 83,
83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
83, 84, 86, 85, 87, 85, 88, 88, 88, 89,
89, 90, 90, 90, 90, 90, 90, 90, 90, 90,
90, 91, 91, 91, 91, 92, 92, 93, 93, 93,
93, 94, 95, 93, 96, 96, 96, 96, 96, 96,
96, 97, 97, 98, 98, 99, 99, 99, 99, 99,
99, 99, 100, 100, 100, 100, 100, 100, 100
};
static const short yyr2[] = { 0,
1, 2, 0, 3, 1, 1, 1, 1, 1, 2,
0, 3, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 0, 1, 0, 0, 5, 0,
1, 1, 2, 1, 1, 1, 3, 3, 1, 0,
4, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 0, 3, 0, 3, 1, 1, 1, 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 2, 1, 1, 1,
3, 0, 0, 6, 0, 1, 1, 1, 1, 1,
2, 0, 2, 1, 2, 0, 1, 1, 1, 1,
1, 2, 1, 1, 1, 1, 1, 1, 1
};
static const short yydefact[] = { 0,
49, 92, 93, 95, 94, 82, 83, 84, 85, 86,
87, 88, 89, 90, 91, 46, 47, 48, 56, 50,
51, 52, 53, 54, 44, 45, 57, 55, 77, 78,
75, 58, 59, 79, 60, 61, 62, 63, 64, 65,
66, 67, 68, 69, 70, 71, 98, 99, 100, 3,
5, 102, 105, 0, 1, 8, 42, 43, 72, 73,
6, 7, 9, 96, 80, 0, 116, 106, 107, 108,
110, 109, 0, 0, 2, 80, 97, 81, 76, 14,
27, 15, 16, 17, 18, 19, 20, 21, 22, 23,
24, 4, 0, 11, 13, 117, 118, 119, 121, 120,
0, 0, 114, 123, 124, 125, 129, 126, 128, 127,
111, 101, 74, 0, 10, 25, 122, 103, 115, 28,
12, 26, 112, 30, 0, 104, 34, 35, 36, 39,
116, 105, 0, 29, 31, 32, 113, 0, 0, 40,
33, 37, 38, 30, 41, 0, 0
};
static const short yydefgoto[] = { 54,
55, 66, 92, 93, 116, 94, 121, 95, 114, 124,
134, 135, 136, 144, 56, 57, 58, 59, 76, 65,
60, 79, 61, 62, 63, 64, 67, 123, 74, 126,
102, 103, 111
};
static const short yypact[] = { 58,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768, -58, 0,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768, 121,-32768, -54, 122, 113,-32768,-32768,-32768,
-32768,-32768, 77, -55,-32768, -54,-32768,-32768,-32768,-32768,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768, -52,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
77, 85,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,-32768, -47,-32768, 121,-32768,-32768,-32768,-32768,
-32768, 121, -53, 97, 5,-32768,-32768,-32768,-32768,-32768,
113, -58, 6,-32768, 97,-32768,-32768, 105, 74,-32768,
-32768,-32768,-32768, 97,-32768, 70,-32768
};
static const short yypgoto[] = {-32768,
17,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
4,-32768, 18,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768, 76,-32768,-32768, 39, -56,-32768,-32768, 36,-32768,
45, 22, 82
};
#define YYLAST 186
static const short yytable[] = { 146,
68, 69, 70, 71, 78, 72, 77, 73, 1, 112,
115, 120, 125, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 51, 52, 53, 77, 1, 137, 140, 147,
75, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, 52, 53, 119, 80, 81, 82, 83, 84, 85,
86, 87, 88, 89, 90, 104, 105, 106, 143, 107,
108, 109, 110, 96, 97, 98, 99, 145, 118, 100,
101, 113, 141, 91, 122, 127, 128, 129, 130, 119,
131, 132, 133, 96, 97, 98, 99, 139, 142, 100,
101, 96, 97, 98, 99, 138, 0, 100, 101, 47,
48, 49, 117, 0, 52, 53
};
static const short yycheck[] = { 0,
59, 60, 61, 62, 59, 64, 63, 66, 9, 65,
63, 59, 66, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
61, 62, 63, 64, 65, 122, 9, 63, 63, 0,
54, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
63, 64, 65, 102, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 59, 60, 61, 65, 63,
64, 65, 66, 59, 60, 61, 62, 144, 64, 65,
66, 76, 135, 32, 116, 59, 60, 61, 62, 138,
64, 65, 66, 59, 60, 61, 62, 132, 64, 65,
66, 59, 60, 61, 62, 131, -1, 65, 66, 59,
60, 61, 101, -1, 64, 65
};
#define YYPURE 1
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
#line 3 "/gnu/lib/bison.simple"
/* Skeleton output parser for bison,
Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Added for Amiga SASC , and replaced fprintf(stderr,...) to printf(...)
Stefan Ruppert */
#ifdef __SASC
#ifndef alloca
#define alloca malloc
#endif
#ifdef printf
#undef printf
#endif
#define printf Printf
static void __yy_bcopy (char *from,char *to,int count);
#endif
#ifndef alloca
#ifdef __GNUC__
#define alloca __builtin_alloca
#else /* not GNU C. */
#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
#include <alloca.h>
#else /* not sparc */
#if defined (MSDOS) && !defined (__TURBOC__)
#include <malloc.h>
#else /* not MSDOS, or __TURBOC__ */
#if defined(_AIX)
#include <malloc.h>
#pragma alloca
#else /* not MSDOS, __TURBOC__, or _AIX */
#ifdef __hpux
#ifdef __cplusplus
extern "C" {
void *alloca (unsigned int);
};
#else /* not __cplusplus */
void *alloca ();
#endif /* not __cplusplus */
#endif /* __hpux */
#endif /* not _AIX */
#endif /* not MSDOS, or __TURBOC__ */
#endif /* not sparc. */
#endif /* not GNU C. */
#endif /* alloca not defined. */
/* This is the parser code that is written into each bison parser
when the %semantic_parser declaration is not specified in the grammar.
It was written by Richard Stallman by simplifying the hairy parser
used when %semantic_parser is specified. */
/* Note: there must be only one dollar sign in this file.
It is replaced by the list of actions, each action
as one case of the switch. */
#define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY)
#define YYEMPTY -2
#define YYEOF 0
#define YYACCEPT return(0)
#define YYABORT return(1)
#define YYERROR goto yyerrlab1
/* Like YYERROR except do call yyerror.
This remains here temporarily to ease the
transition to the new meaning of YYERROR, for GCC.
Once GCC version 2 has supplanted version 1, this can go. */
#define YYFAIL goto yyerrlab
#define YYRECOVERING() (!!yyerrstatus)
#define YYBACKUP(token, value) \
do \
if (yychar == YYEMPTY && yylen == 1) \
{ yychar = (token), yylval = (value); \
yychar1 = YYTRANSLATE (yychar); \
YYPOPSTACK; \
goto yybackup; \
} \
else \
{ yyerror ("syntax error: cannot back up"); YYERROR; } \
while (0)
#define YYTERROR 1
#define YYERRCODE 256
#ifndef YYPURE
#define YYLEX yylex()
#endif
#ifdef YYPURE
#ifdef YYLSP_NEEDED
#define YYLEX yylex(&yylval, &yylloc)
#else
#define YYLEX yylex(&yylval)
#endif
#endif
/* If nonreentrant, generate the variables here */
#ifndef YYPURE
int yychar; /* the lookahead symbol */
YYSTYPE yylval; /* the semantic value of the */
/* lookahead symbol */
#ifdef YYLSP_NEEDED
YYLTYPE yylloc; /* location data for the lookahead */
/* symbol */
#endif
int yynerrs; /* number of parse errors so far */
#endif /* not YYPURE */
#if YYDEBUG != 0
int yydebug; /* nonzero means print parse trace */
/* Since this is uninitialized, it does not stop multiple parsers
from coexisting. */
#endif
/* YYINITDEPTH indicates the initial size of the parser's stacks */
#ifndef YYINITDEPTH
#define YYINITDEPTH 200
#endif
/* YYMAXDEPTH is the maximum size the stacks can grow to
(effective only if the built-in stack extension method is used). */
#if YYMAXDEPTH == 0
#undef YYMAXDEPTH
#endif
#ifndef YYMAXDEPTH
#define YYMAXDEPTH 10000
#endif
/* Prevent warning if -Wstrict-prototypes. */
#ifdef __GNUC__
int yyparse(struct ClassBase *cb,struct CParse *cparse);
#endif
#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
#define __yy_bcopy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT)
#else /* not GNU C or C++ */
#ifndef __cplusplus
/* This is the most reliable way to avoid incompatibilities
in available built-in functions on various systems. */
static void
__yy_bcopy (from, to, count)
char *from;
char *to;
int count;
{
register char *f = from;
register char *t = to;
register int i = count;
while (i-- > 0)
*t++ = *f++;
}
#else /* __cplusplus */
/* This is the most reliable way to avoid incompatibilities
in available built-in functions on various systems. */
static void
__yy_bcopy (char *from, char *to, int count)
{
register char *f = from;
register char *t = to;
register int i = count;
while (i-- > 0)
*t++ = *f++;
}
#endif
#endif
#line 184 "/gnu/lib/bison.simple"
int
yyparse(struct ClassBase *cb,struct CParse *cparse)
{
register int yystate;
register int yyn;
register short *yyssp;
register YYSTYPE *yyvsp;
int yyerrstatus; /* number of tokens to shift before error messages enabled */
int yychar1; /* lookahead token as an internal (translated) token number */
short yyssa[YYINITDEPTH]; /* the state stack */
YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
short *yyss = yyssa; /* refer to the stacks thru separate pointers */
YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
#ifdef YYLSP_NEEDED
YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
YYLTYPE *yyls = yylsa;
YYLTYPE *yylsp;
#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
#else
#define YYPOPSTACK (yyvsp--, yyssp--)
#endif
int yystacksize = YYINITDEPTH;
#ifdef YYPURE
int yychar;
YYSTYPE yylval;
int yynerrs;
#ifdef YYLSP_NEEDED
YYLTYPE yylloc;
#endif
#endif
YYSTYPE yyval; /* the variable used to return */
/* semantic values from the action */
/* routines */
int yylen;
#if YYDEBUG != 0
if (yydebug)
printf( "Starting parse\n");
#endif
yystate = 0;
yyerrstatus = 0;
yynerrs = 0;
yychar = YYEMPTY; /* Cause a token to be read. */
/* Initialize stack pointers.
Waste one element of value and location stack
so that they stay on the same level as the state stack.
The wasted elements are never initialized. */
yyssp = yyss - 1;
yyvsp = yyvs;
#ifdef YYLSP_NEEDED
yylsp = yyls;
#endif
/* Push a new state, which is found in yystate . */
/* In all cases, when you get here, the value and location stacks
have just been pushed. so pushing a state here evens the stacks. */
yynewstate:
*++yyssp = yystate;
if (yyssp >= yyss + yystacksize - 1)
{
/* Give user a chance to reallocate the stack */
/* Use copies of these so that the &'s don't force the real ones into memory. */
YYSTYPE *yyvs1 = yyvs;
short *yyss1 = yyss;
#ifdef YYLSP_NEEDED
YYLTYPE *yyls1 = yyls;
#endif
/* Get the current used size of the three stacks, in elements. */
int size = yyssp - yyss + 1;
#ifdef yyoverflow
/* Each stack pointer address is followed by the size of
the data in use in that stack, in bytes. */
#ifdef YYLSP_NEEDED
/* This used to be a conditional around just the two extra args,
but that might be undefined if yyoverflow is a macro. */
yyoverflow("parser stack overflow",
&yyss1, size * sizeof (*yyssp),
&yyvs1, size * sizeof (*yyvsp),
&yyls1, size * sizeof (*yylsp),
&yystacksize);
#else
yyoverflow("parser stack overflow",
&yyss1, size * sizeof (*yyssp),
&yyvs1, size * sizeof (*yyvsp),
&yystacksize);
#endif
yyss = yyss1; yyvs = yyvs1;
#ifdef YYLSP_NEEDED
yyls = yyls1;
#endif
#else /* no yyoverflow */
/* Extend the stack our own way. */
if (yystacksize >= YYMAXDEPTH)
{
yyerror("parser stack overflow");
return 2;
}
yystacksize *= 2;
if (yystacksize > YYMAXDEPTH)
yystacksize = YYMAXDEPTH;
yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
__yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
__yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
#ifdef YYLSP_NEEDED
yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
__yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
#endif
#endif /* no yyoverflow */
yyssp = yyss + size - 1;
yyvsp = yyvs + size - 1;
#ifdef YYLSP_NEEDED
yylsp = yyls + size - 1;
#endif
#if YYDEBUG != 0
if (yydebug)
printf( "Stack size increased to %ld\n", yystacksize);
#endif
if (yyssp >= yyss + yystacksize - 1)
YYABORT;
}
#if YYDEBUG != 0
if (yydebug)
printf( "Entering state %ld\n", yystate);
#endif
goto yybackup;
yybackup:
/* Do appropriate processing given the current state. */
/* Read a lookahead token if we need one and don't already have one. */
/* yyresume: */
/* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate];
if (yyn == YYFLAG)
goto yydefault;
/* Not known => get a lookahead token if don't already have one. */
/* yychar is either YYEMPTY or YYEOF
or a valid token in external form. */
if (yychar == YYEMPTY)
{
#if YYDEBUG != 0
if (yydebug)
printf( "Reading a token: ");
#endif
yychar = yylex(&yylval,cb,cparse);
}
/* Convert token to internal form (in yychar1) for indexing tables with */
if (yychar <= 0) /* This means end of input. */
{
yychar1 = 0;
yychar = YYEOF; /* Don't call YYLEX any more */
#if YYDEBUG != 0
if (yydebug)
printf( "Now at end of input.\n");
#endif
}
else
{
yychar1 = YYTRANSLATE(yychar);
#if YYDEBUG != 0
if (yydebug)
{
printf ("Next token is %ld (%s", yychar, yytname[yychar1]);
/* Give the individual parser a way to print the precise meaning
of a token, for further debugging info. */
#ifdef YYPRINT
YYPRINT (yychar, yylval);
#endif
printf (")\n");
}
#endif
}
yyn += yychar1;
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
goto yydefault;
yyn = yytable[yyn];
/* yyn is what to do for this token type in this state.
Negative => reduce, -yyn is rule number.
Positive => shift, yyn is new state.
New state is final state => don't bother to shift,
just return success.
0, or most negative number => error. */
if (yyn < 0)
{
if (yyn == YYFLAG)
goto yyerrlab;
yyn = -yyn;
goto yyreduce;
}
else if (yyn == 0)
goto yyerrlab;
if (yyn == YYFINAL)
YYACCEPT;
/* Shift the lookahead token. */
#if YYDEBUG != 0
if (yydebug)
printf( "Shifting token %ld (%s), ", yychar, yytname[yychar1]);
#endif
/* Discard the token being shifted unless it is eof. */
if (yychar != YYEOF)
yychar = YYEMPTY;
*++yyvsp = yylval;
#ifdef YYLSP_NEEDED
*++yylsp = yylloc;
#endif
/* count tokens shifted since error; after three, turn off error status. */
if (yyerrstatus) yyerrstatus--;
yystate = yyn;
goto yynewstate;
/* Do the default action for the current state. */
yydefault:
yyn = yydefact[yystate];
if (yyn == 0)
goto yyerrlab;
/* Do a reduction. yyn is the number of a rule to reduce with. */
yyreduce:
yylen = yyr2[yyn];
if (yylen > 0)
yyval = yyvsp[1-yylen]; /* implement default value of the action */
#if YYDEBUG != 0
if (yydebug)
{
int i;
printf ("Reducing via rule %ld (line %ld), ",
yyn, yyrline[yyn]);
/* Print the symbols being reduced, and their result. */
for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
printf ("%s ", yytname[yyrhs[i]]);
printf (" -> %s\n", yytname[yyr1[yyn]]);
}
#endif
switch (yyn) {
case 3:
#line 204 "cdt.y"
{ cparse->Mode = C_CPP; ;
break;}
case 4:
#line 205 "cdt.y"
{ cparse->Mode = C_STANDARD; ;
break;}
case 5:
#line 206 "cdt.y"
{ add_cexpr(cb,cparse,C_STANDARD,LNF_LF); ;
break;}
case 6:
#line 207 "cdt.y"
{ add_cexpr(cb,cparse,C_TYPES,0); ;
break;}
case 7:
#line 208 "cdt.y"
{ add_cexpr(cb,cparse,C_STORAGE,0); ;
break;}
case 10:
#line 214 "cdt.y"
{ add_cexpr(cb,cparse,C_STANDARD,LNF_LF); ;
break;}
case 11:
#line 218 "cdt.y"
{ add_cexpr(cb,cparse,C_CPP,0); cparse->Mode = C_CPPTEXTLIST; ;
break;}
case 27:
#line 242 "cdt.y"
{ add_cexpr(cb,cparse,C_CPP,0); cparse->Mode = C_CPPTEXTLIST; cparse->TxtPtr = cparse->ActPtr; ;
break;}
case 28:
#line 243 "cdt.y"
{ cparse->TxtPtr = cparse->ActPtr; ;
break;}
case 32:
#line 252 "cdt.y"
{ if(cparse->XOffsetAdd) add_cexpr(cb,cparse,C_STANDARD,0);
cparse->TxtPtr = cparse->ActPtr; ;
break;}
case 33:
#line 254 "cdt.y"
{ if(cparse->XOffsetAdd) add_cexpr(cb,cparse,C_STANDARD,0);
cparse->TxtPtr = cparse->ActPtr; ;
break;}
case 36:
#line 261 "cdt.y"
{ add_cexpr(cb,cparse,C_NUMBER,0); ;
break;}
case 37:
#line 262 "cdt.y"
{ add_cexpr(cb,cparse,C_STRING,0); ;
break;}
case 38:
#line 263 "cdt.y"
{ add_cexpr(cb,cparse,C_STRING,0); ;
break;}
case 39:
#line 264 "cdt.y"
{ cparse->TxtPtr = cparse->ActPtr; ;
break;}
case 40:
#line 265 "cdt.y"
{ add_cexpr(cb,cparse,C_STANDARD,LNF_LF); ;
break;}
case 42:
#line 272 "cdt.y"
{ add_cexpr(cb,cparse,C_KEYWORD,0); ;
break;}
case 73:
#line 311 "cdt.y"
{ add_cexpr(cb,cparse,C_KEYWORD,0); ;
break;}
case 75:
#line 313 "cdt.y"
{ add_cexpr(cb,cparse,C_KEYWORD,0); ;
break;}
case 81:
#line 324 "cdt.y"
{ add_cexpr(cb,cparse,C_TYPENAME,0); ;
break;}
case 96:
#line 348 "cdt.y"
{ if(cparse->XOffsetAdd) add_cexpr(cb,cparse,C_STANDARD,0);
cparse->TxtPtr = cparse->ActPtr; ;
break;}
case 97:
#line 350 "cdt.y"
{ if(cparse->XOffsetAdd) add_cexpr(cb,cparse,C_STANDARD,0);
cparse->TxtPtr = cparse->ActPtr; ;
break;}
case 98:
#line 355 "cdt.y"
{ ;
break;}
case 100:
#line 357 "cdt.y"
{ add_cexpr(cb,cparse,C_NUMBER,0); ;
break;}
case 101:
#line 360 "cdt.y"
{ add_cexpr(cb,cparse,C_STRING,0); ;
break;}
case 102:
#line 361 "cdt.y"
{ cparse->ActPtr--;add_cexpr(cb,cparse,C_STANDARD,0);
cparse->ActPtr++;cparse->Mode = C_STRING; ;
break;}
case 103:
#line 364 "cdt.y"
{ add_cexpr(cb,cparse,C_STRING,0);
cparse->Mode = C_STANDARD; ;
break;}
case 113:
#line 380 "cdt.y"
{ add_cexpr(cb,cparse,C_STANDARD,LNF_LF); ;
break;}
case 129:
#line 405 "cdt.y"
{ add_cexpr(cb,cparse,C_STRING,LNF_LF); ;
break;}
}
/* the action file gets copied in in place of this dollarsign */
#line 465 "/gnu/lib/bison.simple"
yyvsp -= yylen;
yyssp -= yylen;
#ifdef YYLSP_NEEDED
yylsp -= yylen;
#endif
#if YYDEBUG != 0
if (yydebug)
{
short *ssp1 = yyss - 1;
printf ("state stack now");
while (ssp1 != yyssp)
printf (" %ld", *++ssp1);
printf ("\n");
}
#endif
*++yyvsp = yyval;
#ifdef YYLSP_NEEDED
yylsp++;
if (yylen == 0)
{
yylsp->first_line = yylloc.first_line;
yylsp->first_column = yylloc.first_column;
yylsp->last_line = (yylsp-1)->last_line;
yylsp->last_column = (yylsp-1)->last_column;
yylsp->text = 0;
}
else
{
yylsp->last_line = (yylsp+yylen-1)->last_line;
yylsp->last_column = (yylsp+yylen-1)->last_column;
}
#endif
/* Now "shift" the result of the reduction.
Determine what state that goes to,
based on the state we popped back to
and the rule number reduced by. */
yyn = yyr1[yyn];
yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
yystate = yytable[yystate];
else
yystate = yydefgoto[yyn - YYNTBASE];
goto yynewstate;
yyerrlab: /* here on detecting error */
if (! yyerrstatus)
/* If not already recovering from an error, report this error. */
{
++yynerrs;
#ifdef YYERROR_VERBOSE
yyn = yypact[yystate];
if (yyn > YYFLAG && yyn < YYLAST)
{
int size = 0;
char *msg;
int x, count;
count = 0;
/* Start X at -yyn if nec to avoid negative indexes in yycheck. */
for (x = (yyn < 0 ? -yyn : 0);
x < (sizeof(yytname) / sizeof(char *)); x++)
if (yycheck[x + yyn] == x)
size += strlen(yytname[x]) + 15, count++;
msg = (char *) malloc(size + 15);
if (msg != 0)
{
strcpy(msg, "parse error");
if (count < 5)
{
count = 0;
for (x = (yyn < 0 ? -yyn : 0);
x < (sizeof(yytname) / sizeof(char *)); x++)
if (yycheck[x + yyn] == x)
{
strcat(msg, count == 0 ? ", expecting `" : " or `");
strcat(msg, yytname[x]);
strcat(msg, "'");
count++;
}
}
yyerror(msg);
free(msg);
}
else
yyerror ("parse error; also virtual memory exceeded");
}
else
#endif /* YYERROR_VERBOSE */
cdtparse_parseerror(cb,cparse);
}
goto yyerrlab1;
yyerrlab1: /* here on error raised explicitly by an action */
if (yyerrstatus == 3)
{
/* if just tried and failed to reuse lookahead token after an error, discard it. */
/* return failure if at end of input */
if (yychar == YYEOF)
YYABORT;
#if YYDEBUG != 0
if (yydebug)
printf( "Discarding token %ld (%s).\n", yychar, yytname[yychar1]);
#endif
yychar = YYEMPTY;
}
/* Else will try to reuse lookahead token
after shifting the error token. */
yyerrstatus = 3; /* Each real token shifted decrements this */
goto yyerrhandle;
yyerrdefault: /* current state does not do anything special for the error token. */
#if 0
/* This is wrong; only states that explicitly want error tokens
should shift them. */
yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
if (yyn) goto yydefault;
#endif
yyerrpop: /* pop the current state because it cannot handle the error token */
if (yyssp == yyss) YYABORT;
yyvsp--;
yystate = *--yyssp;
#ifdef YYLSP_NEEDED
yylsp--;
#endif
#if YYDEBUG != 0
if (yydebug)
{
short *ssp1 = yyss - 1;
printf ("Error: state stack now");
while (ssp1 != yyssp)
printf (" %ld", *++ssp1);
printf ("\n");
}
#endif
yyerrhandle:
yyn = yypact[yystate];
if (yyn == YYFLAG)
goto yyerrdefault;
yyn += YYTERROR;
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
goto yyerrdefault;
yyn = yytable[yyn];
if (yyn < 0)
{
if (yyn == YYFLAG)
goto yyerrpop;
yyn = -yyn;
goto yyreduce;
}
else if (yyn == 0)
goto yyerrpop;
if (yyn == YYFINAL)
YYACCEPT;
#if YYDEBUG != 0
if (yydebug)
printf( "Shifting error token, ");
#endif
*++yyvsp = yylval;
#ifdef YYLSP_NEEDED
*++yylsp = yylloc;
#endif
yystate = yyn;
goto yynewstate;
}
#line 408 "cdt.y"
/*FS*/ /*"Keyword definition"*/
struct Keyword
{
STRPTR k_Word;
int k_ID;
int k_Len;
};
struct Keyword keywords[] =
{
{"auto" ,T_AUTO ,4},
{"break" ,T_BREAK ,5},
{"case" ,T_CASE ,4},
{"catch" ,T_CATCH ,5},
{"char" ,T_CHAR ,4},
{"class" ,T_CLASS ,5},
{"const" ,T_CONST ,5},
{"continue" ,T_CONTINUE ,8},
{"default" ,T_DEFAULT ,7},
{"delete" ,T_DELETE ,6},
{"do" ,T_DO ,2},
{"double" ,T_DOUBLE ,6},
{"else" ,T_ELSE ,4},
{"enum" ,T_ENUM ,4},
{"extern" ,T_EXTERN ,6},
{"float" ,T_FLOAT ,5},
{"for" ,T_FOR ,3},
{"friend" ,T_FRIEND ,6},
{"goto" ,T_GOTO ,4},
{"if" ,T_IF ,2},
{"inline" ,T_INLINE ,6},
{"int" ,T_INT ,3},
{"long" ,T_LONG ,4},
{"new" ,T_NEW ,3},
{"operator" ,T_OPERATOR ,8},
{"private" ,T_PRIVATE ,7},
{"protected",T_PROTECTED ,9},
{"public" ,T_PUBLIC ,6},
{"register" ,T_REGISTER ,8},
{"return" ,T_RETURN ,6},
{"short" ,T_SHORT ,5},
{"signed" ,T_SIGNED ,6},
{"sizeof" ,T_SIZEOF ,6},
{"static" ,T_STATIC ,6},
{"struct" ,T_STRUCT ,6},
{"switch" ,T_SWITCH ,6},
{"throw" ,T_THROW ,5},
{"try" ,T_TRY ,3},
{"typedef" ,T_TYPEDEF ,7},
{"union" ,T_UNION ,5},
{"unsigned" ,T_UNSIGNED ,8},
{"virtual" ,T_VIRTUAL ,7},
{"void" ,T_VOID ,4},
{"volatile" ,T_VOLATILE ,8},
{"while" ,T_WHILE ,5},
{NULL ,0}
};
struct Keyword cppkeywords[] =
{
{"define" ,T_DEFINE ,6},
{"elif" ,T_ELIF ,4},
{"else" ,T_ELSE ,4},
{"endif" ,T_ENDIF ,5},
{"error" ,T_ERROR ,5},
{"if" ,T_IF ,2},
{"ifdef" ,T_IFDEF ,5},
{"ifndef" ,T_IFNDEF ,6},
{"include" ,T_INCLUDE ,7},
{"line" ,T_LINE ,4},
{"pragma" ,T_PRAGMA ,6},
{"undef" ,T_UNDEF ,5},
{NULL ,0}
};
/*FE*/
/*FS*/ int cdtparse_lex(int *lvalp,struct ClassBase *cb,struct CParse *cparse)
{
struct CData *cd = cparse->Data;
STRPTR ptr = cparse->ActPtr;
STRPTR end = cparse->EndPtr;
STRPTR name;
ULONG tablen = cd->cd_TabLength;
LONG addx;
struct Keyword *kw = NULL;
int retval = 0;
int len;
if(ptr < end)
{
do
{
while(ptr < end && (*ptr == ' ' || *ptr == '\t'))
{
if(*ptr == '\t')
{
addx = (tablen - (cparse->Chars % tablen));
cparse->XOffsetAdd += addx;
cparse->Chars += addx;
} else
cparse->Chars++;
ptr++;
}
/* handle comments */
if(*ptr == '/' && ptr < end - 1 && (ptr[1] == '*' || ptr[1] == '/') && cparse->Mode != C_STRING)
{
ptr += 2;
if(ptr[-1] == '*')
{
int nested = 1;
while(ptr < end && nested)
{
switch(*ptr)
{
case '*':
if(ptr[1] == '/')
{
nested--;
ptr++;
}
break;
case '/':
if(ptr[1] == '*' && cparse->Data->cd_Flags.Nested)
{
nested++;
ptr++;
}
break;
case '\n':
ptr++;
cparse->ActPtr = ptr;
add_cexpr(cb,cparse,C_COMMENT,LNF_LF);
cparse->Chars = 0;
continue;
case '\t':
cparse->ActPtr = ptr;
if(cparse->Chars)
add_cexpr(cb,cparse,C_COMMENT,0);
while(*ptr == '\t' || *ptr == ' ')
{
if(*ptr == '\t')
{
addx = (tablen - (cparse->Chars % tablen));
cparse->XOffsetAdd += addx;
cparse->Chars += addx;
} else
cparse->Chars++;
ptr++;
}
ptr--;
break;
}
cparse->Chars++;
ptr++;
}
cparse->ActPtr = ptr;
add_cexpr(cb,cparse,C_COMMENT,0);
} else
{
while(ptr < end && *ptr != '\n')
{
if(*ptr == '\t')
{
cparse->ActPtr = ptr;
add_cexpr(cb,cparse,C_COMMENT,0);
while(*ptr == '\t')
{
addx = (tablen - (cparse->Chars % tablen));
cparse->XOffsetAdd += addx;
cparse->Chars += addx;
ptr++;
}
} else
cparse->Chars++;
ptr++;
}
ptr++;
cparse->ActPtr = ptr;
add_cexpr(cb,cparse,C_COMMENT,LNF_LF);
cparse->Chars = 0;
}
} else
break;
} while(*ptr == ' ' || *ptr == '\t' || *ptr == '/');
if(ptr < end)
{
if(isalpha(*ptr) || *ptr == '_')
{
name = ptr;
while(ptr < end && (isalpha(*ptr) || isdigit(*ptr) || *ptr == '_'))
ptr++;
len = (ptr - name);
ptr--;
retval = T_ID;
/* only search for keyword if it is normal text or a cppline !!! */
if(cparse->Mode == C_CPP)
kw = cppkeywords;
else if(cparse->Mode == C_STANDARD)
kw = keywords;
if(len > 1 && kw)
{
int cmp;
while(kw->k_Word)
{
if(!(cmp = strncmp(kw->k_Word,name,len)))
{
DB(("len = %ld , strlen(kw) = %ld\n",len,kw->k_Len));
if(len == kw->k_Len)
{
retval = kw->k_ID;
break;
}
} else if(cmp > 0)
break;
kw++;
}
/* try user defined type keywords */
if(cmp)
{
struct Node *node;
for(node = cd->cd_UserTypes.lh_Head ; node->ln_Succ ; node = node->ln_Succ)
{
if(len == node->ln_Type && !strncmp(node->ln_Name,name,len))
{
retval = T_USERTYPE;
break;
}
}
}
}
cparse->Chars += len;
cparse->ActPtr = ptr + 1;
} else if(isdigit(*ptr))
{
name = ptr;
ptr++;
if(*ptr == 'x')
{
ptr++;
while(ptr < end && isxdigit(*ptr))
ptr++;
} else
{
while(ptr < end && isdigit(*ptr))
ptr++;
}
ptr--;
cparse->Chars += (ptr - name);
cparse->ActPtr = ptr + 1;
retval = T_NUMBER;
} else
{
retval = T_CHR;
cparse->Chars++;
switch(*ptr)
{
case '\n':
cparse->Chars = 0;
case '"':
case '#':
case '\\':
case '\'':
retval = *ptr;
break;
}
cparse->ActPtr = ptr + 1;
}
}
}
DB(("token : %ld\n",retval));
cparse->Token = retval;
return(retval);
}
/*FE*/
/*FS*/ void *cdtparse_alloc(struct ClassBase *cb,struct CParse *cparse,int size)
{
struct cdtMem *mem;
if((mem = AllocPooled(cparse->Data->cd_Pool,size + sizeof(struct cdtMem))))
{
mem->Next = cparse->Memory;
mem->Size = size + sizeof(struct cdtMem);
mem++;
}
return(mem);
}
/*FE*/
/*FS*/ void cdtparse_free(struct ClassBase *cb,struct CParse *cparse)
{
struct cdtMem *mem = cparse->Memory;
struct cdtMem *next;
while(mem)
{
next = mem->Next;
mem--;
FreePooled(cparse->Data->cd_Pool,mem,mem->Size);
mem = next;
}
}
/*FE*/
/*FS*/ int cdtparse_error(char *str)
{
DB(("error : %s\n",str));
return(0);
}
/*FE*/
/*FS*/ void cdtparse_parseerror(struct ClassBase *cb,struct CParse *cparse)
{
char *buf;
if((buf = AllocPooled(cparse->Data->cd_Pool,50)))
{
STRPTR seg = cparse->SegPtr;
STRPTR act = cparse->ActPtr;
sprintf(buf,"Parse Error : last Token %4ld for line :",cparse->Token);
cparse->SegPtr = buf;
cparse->ActPtr = buf + strlen(buf);
add_line(cb,cparse,C_STANDARD,LNF_LF);
while(seg > cparse->BegPtr && *seg != '\n')
seg--;
if(*seg == '\n')
seg++;
while(act < cparse->EndPtr && *act != '\n')
act++;
cparse->SegPtr = seg;
cparse->ActPtr = act;
add_line(cb,cparse,C_STANDARD,LNF_LF);
}
}
/*FE*/
@
39.12
log
@*** empty log message ***
@
text
@d79 1
a79 1
** $VER: cdt.y 39.11 (04.06.95)
d90 1
d356 13
a368 13
198, 199, 202, 204, 205, 206, 207, 208, 209, 212,
216, 219, 219, 222, 224, 225, 226, 227, 228, 229,
230, 231, 232, 233, 236, 237, 240, 242, 244, 246,
247, 250, 253, 257, 259, 260, 261, 262, 263, 264,
266, 270, 272, 274, 276, 277, 278, 279, 280, 281,
282, 283, 284, 285, 286, 287, 288, 289, 290, 291,
292, 293, 294, 295, 296, 297, 298, 299, 300, 301,
302, 305, 309, 312, 312, 314, 316, 318, 319, 322,
323, 326, 328, 329, 330, 331, 332, 333, 334, 335,
336, 339, 341, 342, 343, 346, 349, 353, 355, 356,
357, 360, 363, 366, 368, 369, 370, 371, 372, 373,
374, 378, 379, 382, 384, 388, 389, 390, 391, 392,
393, 394, 397, 399, 400, 401, 402, 403, 404
d999 1
a999 1
#line 203 "cdt.y"
d1003 1
a1003 1
#line 204 "cdt.y"
d1007 1
a1007 1
#line 205 "cdt.y"
d1011 1
a1011 1
#line 206 "cdt.y"
d1015 1
a1015 1
#line 207 "cdt.y"
d1019 1
a1019 1
#line 213 "cdt.y"
d1023 1
a1023 1
#line 217 "cdt.y"
d1027 2
a1028 2
#line 241 "cdt.y"
{ add_cexpr(cb,cparse,C_CPP,0); cparse->Mode = C_CPPTEXTLIST; ;
d1031 1
a1031 1
#line 242 "cdt.y"
d1035 1
a1035 1
#line 251 "cdt.y"
d1040 1
a1040 1
#line 253 "cdt.y"
d1045 1
a1045 1
#line 260 "cdt.y"
d1049 1
a1049 1
#line 261 "cdt.y"
d1053 1
a1053 1
#line 262 "cdt.y"
d1057 1
a1057 1
#line 263 "cdt.y"
d1061 1
a1061 1
#line 264 "cdt.y"
d1065 1
a1065 1
#line 271 "cdt.y"
d1069 1
a1069 1
#line 310 "cdt.y"
d1073 1
a1073 1
#line 312 "cdt.y"
d1077 1
a1077 1
#line 323 "cdt.y"
d1081 1
a1081 1
#line 347 "cdt.y"
d1086 1
a1086 1
#line 349 "cdt.y"
d1091 1
a1091 1
#line 354 "cdt.y"
d1095 1
a1095 1
#line 356 "cdt.y"
d1099 1
a1099 1
#line 359 "cdt.y"
d1103 1
a1103 1
#line 360 "cdt.y"
d1108 1
a1108 1
#line 363 "cdt.y"
d1113 1
a1113 1
#line 379 "cdt.y"
d1117 1
a1117 1
#line 404 "cdt.y"
d1318 1
a1318 1
#line 407 "cdt.y"
d1413 1
d1493 1
a1493 2
if(cparse->Chars)
add_cexpr(cb,cparse,C_COMMENT,0);
@
39.11
log
@*** empty log message ***
@
text
@d79 1
a79 1
** $VER: cdt.y 39.10 (10.05.95)
d90 1
d355 13
a367 13
197, 198, 201, 203, 204, 205, 206, 207, 208, 211,
215, 218, 218, 221, 223, 224, 225, 226, 227, 228,
229, 230, 231, 232, 235, 236, 239, 241, 243, 245,
246, 249, 252, 256, 258, 259, 260, 261, 262, 263,
265, 269, 271, 273, 275, 276, 277, 278, 279, 280,
281, 282, 283, 284, 285, 286, 287, 288, 289, 290,
291, 292, 293, 294, 295, 296, 297, 298, 299, 300,
301, 304, 308, 311, 311, 313, 315, 317, 318, 321,
322, 325, 327, 328, 329, 330, 331, 332, 333, 334,
335, 338, 340, 341, 342, 345, 348, 352, 354, 355,
356, 359, 362, 365, 367, 368, 369, 370, 371, 372,
373, 377, 378, 381, 383, 387, 388, 389, 390, 391,
392, 393, 396, 398, 399, 400, 401, 402, 403
d998 1
a998 1
#line 202 "cdt.y"
d1002 1
a1002 1
#line 203 "cdt.y"
d1006 1
a1006 1
#line 204 "cdt.y"
d1010 1
a1010 1
#line 205 "cdt.y"
d1014 1
a1014 1
#line 206 "cdt.y"
d1018 1
a1018 1
#line 212 "cdt.y"
d1022 1
a1022 1
#line 216 "cdt.y"
d1026 1
a1026 1
#line 240 "cdt.y"
d1030 1
a1030 1
#line 241 "cdt.y"
d1034 1
a1034 1
#line 250 "cdt.y"
d1039 1
a1039 1
#line 252 "cdt.y"
d1044 1
a1044 1
#line 259 "cdt.y"
d1048 1
a1048 1
#line 260 "cdt.y"
d1052 1
a1052 1
#line 261 "cdt.y"
d1056 1
a1056 1
#line 262 "cdt.y"
d1060 1
a1060 1
#line 263 "cdt.y"
d1064 1
a1064 1
#line 270 "cdt.y"
d1068 1
a1068 1
#line 309 "cdt.y"
d1072 1
a1072 1
#line 311 "cdt.y"
d1076 1
a1076 1
#line 322 "cdt.y"
d1080 1
a1080 1
#line 346 "cdt.y"
d1085 1
a1085 1
#line 348 "cdt.y"
d1090 1
a1090 1
#line 353 "cdt.y"
d1094 1
a1094 1
#line 355 "cdt.y"
d1098 1
a1098 1
#line 358 "cdt.y"
d1102 1
a1102 1
#line 359 "cdt.y"
d1107 1
a1107 1
#line 362 "cdt.y"
d1112 1
a1112 1
#line 378 "cdt.y"
d1116 1
a1116 1
#line 403 "cdt.y"
d1317 1
a1317 1
#line 406 "cdt.y"
@
39.10
log
@*** empty log message ***
@
text
@d79 1
a79 1
** $VER: cdt.y 39.9 (28.04.95)
d90 1
d104 1
a104 1
void add_line(struct ClassBase *cb,struct CParse *cparse,ULONG index,UWORD flags)
d114 1
a115 1
ULONG x = cparse->XOffsetAdd;
d117 1
a117 1
while(*ptr == ' ' || *ptr == '\t')
d119 28
a146 3
if(*ptr == ' ')
x += cparse->TabWidth;
ptr++;
d150 1
d162 1
a162 1
line->ln_XOffset = cparse->XOffset + x;
d164 1
a164 1
line->ln_Width = TextLength(cparse->RPort,line->ln_Text,line->ln_TextLen) + x;
d202 1
d204 1
a204 1
void add_cexpr(struct ClassBase *cb,struct CParse *cparse,ULONG index,BOOL lf)
d227 1
d354 13
a366 13
168, 169, 172, 174, 175, 176, 177, 178, 179, 182,
186, 189, 189, 192, 194, 195, 196, 197, 198, 199,
200, 201, 202, 203, 206, 207, 210, 212, 214, 216,
217, 220, 223, 227, 229, 230, 231, 232, 233, 234,
236, 240, 242, 244, 246, 247, 248, 249, 250, 251,
252, 253, 254, 255, 256, 257, 258, 259, 260, 261,
262, 263, 264, 265, 266, 267, 268, 269, 270, 271,
272, 275, 279, 282, 282, 284, 286, 288, 289, 292,
293, 296, 298, 299, 300, 301, 302, 303, 304, 305,
306, 309, 311, 312, 313, 316, 319, 323, 325, 326,
327, 330, 333, 336, 338, 339, 340, 341, 342, 343,
344, 348, 349, 352, 354, 358, 359, 360, 361, 362,
363, 364, 367, 369, 370, 371, 372, 373, 374
d997 1
a997 1
#line 173 "cdt.y"
d1001 1
a1001 1
#line 174 "cdt.y"
d1005 1
a1005 1
#line 175 "cdt.y"
d1009 1
a1009 1
#line 176 "cdt.y"
d1013 1
a1013 1
#line 177 "cdt.y"
d1017 1
a1017 1
#line 183 "cdt.y"
d1021 1
a1021 1
#line 187 "cdt.y"
d1025 1
a1025 1
#line 211 "cdt.y"
d1029 1
a1029 1
#line 212 "cdt.y"
d1033 1
a1033 1
#line 221 "cdt.y"
d1038 1
a1038 1
#line 223 "cdt.y"
d1043 1
a1043 1
#line 230 "cdt.y"
d1047 1
a1047 1
#line 231 "cdt.y"
d1051 1
a1051 1
#line 232 "cdt.y"
d1055 1
a1055 1
#line 233 "cdt.y"
d1059 1
a1059 1
#line 234 "cdt.y"
d1063 1
a1063 1
#line 241 "cdt.y"
d1067 1
a1067 1
#line 280 "cdt.y"
d1071 1
a1071 1
#line 282 "cdt.y"
d1075 1
a1075 1
#line 293 "cdt.y"
d1079 1
a1079 1
#line 317 "cdt.y"
d1084 1
a1084 1
#line 319 "cdt.y"
d1089 1
a1089 1
#line 324 "cdt.y"
d1093 1
a1093 1
#line 326 "cdt.y"
d1097 1
a1097 1
#line 329 "cdt.y"
d1101 1
a1101 1
#line 330 "cdt.y"
d1106 1
a1106 1
#line 333 "cdt.y"
d1111 1
a1111 1
#line 349 "cdt.y"
d1115 1
a1115 1
#line 374 "cdt.y"
d1316 1
a1316 1
#line 377 "cdt.y"
d1319 1
d1393 1
d1395 1
a1395 1
int cdtparse_lex(int *lvalp,struct ClassBase *cb,struct CParse *cparse)
d1402 1
a1402 1
LONG addx,chrs;
a1410 1
chrs = cparse->Chars;
d1417 1
a1417 4
if(chrs)
cparse->XOffsetAdd += addx * cparse->TabWidth;
else
cparse->XOffset += addx * cparse->TabWidth;
d1459 1
a1459 2
chrs = cparse->Chars;
if(chrs)
d1461 1
d1468 1
a1468 4
if(chrs > 0)
cparse->XOffsetAdd += addx * cparse->TabWidth;
else
cparse->XOffset += addx * cparse->TabWidth;
d1489 4
a1492 2
add_cexpr(cb,cparse,C_COMMENT,0);
chrs = cparse->Chars;
d1497 1
a1497 4
if(chrs)
cparse->XOffsetAdd += addx * cparse->TabWidth;
else
cparse->XOffset += addx * cparse->TabWidth;
d1562 1
a1562 1
if(!strncmp(node->ln_Name,name,len) && len == node->ln_Type)
d1619 1
d1621 1
a1621 1
void *cdtparse_alloc(struct ClassBase *cb,struct CParse *cparse,int size)
d1634 2
a1635 2
void cdtparse_free(struct ClassBase *cb,struct CParse *cparse)
d1648 1
d1650 1
a1650 1
int cdtparse_error(char *str)
d1655 2
a1656 2
void cdtparse_parseerror(struct ClassBase *cb,struct CParse *cparse)
d1683 1
@